#!/usr/local/bin/python3
# -*- coding: utf-8 -*-
#
#  Cli.py
#
#  Copyright 2011 Arne Hüffmeier <ahueffme@gmail.com>
#
#  This program is free software; you can redistribute it and/or modify
#  it under the terms of the GNU General Public License as published by
#  the Free Software Foundation; either version 2 of the License, or
#  (at your option) any later version.
#
#  This program is distributed in the hope that it will be useful,
#  but WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#  GNU General Public License for more details.
#
#  You should have received a copy of the GNU General Public License
#  along with this program; if not, write to the Free Software
#  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
#  MA 02110-1301, USA.
#

from GuiInterfacesF import GuiInterface
import textwrap


class Cli(GuiInterface):

	def __init__(self):
		super(Cli, self).__init__()

	def setDirCount(self, dirCount):
		pass

#TODO: Modify mit einbauen.
	def changeList(self, serie, season, cList):
		index = 0
		print("Serie:", serie, "Season:", season)
		for j in cList:
			print(str(index) + ")", j[0], "=", j[1].filename())
			index += 1

		input_var = input("Is that correct? (y = yes, n = no)")
		if input_var is "y":
			return cList
		elif input_var is "n":
			return None
			#input_two = input("Do you want to modify? (y = yes, n = no)")
			#if input_two is "n" :
			#	return None
			#elif input_two is "y":

	def choseSerie(self, serienList):
		index = 0
		for i in serienList:
			print(index, "\t", i.name, "(" + i.serienId + ")")
			if i.overview is not None:
				temp = textwrap.wrap(i.overview, 80)
				for j in temp:
					print(j)
				print("\n\n")
			index += 1
		print("\n")
		while True:
			input_var = input("Chose one:  (n = cancel)")
			if input_var is "n":
				return None
			try:
				if int(input_var) >= 0 and int(input_var) < len(serienList):
					return serienList[int(input_var)].serienId
				else:
					print ("input incorect")
			except ValueError:
				print ("plase give a number.")
